#!/usr/bin/env php
<?php

use Imi\App;
use Swoole\Event;

require dirname(__DIR__) . '/vendor/autoload.php';
ini_set('date.timezone', date_default_timezone_get());

App::initFramework('Imi\MQTT');

$statusCode = 0;
go(function() use(&$statusCode){
    go(function() use(&$statusCode){
        try {
            if($phpunitPath = getenv('TEST_PHPUNIT_PATH'))
            {
                require $phpunitPath;
            }
            PHPUnit\TextUI\Command::main();
        } catch (\Swoole\ExitException $e) {
            $statusCode = $e->getStatus();
        }
        Event::exit();
    });
});
Event::wait();
exit($statusCode);
